//-----------------------------------------------------------------------------
// File: Shape.cs
//
// Copyright (c) Dmitry Shuklin. All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Direct3D = Microsoft.DirectX.Direct3D;

namespace Cerebrum.Direct3D.Forms
{
	/// <summary>
	/// Summary description for Frame.
	/// </summary>
	public class ShapeControl : Cerebrum.Direct3D.Forms.Control
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ShapeControl(System.ComponentModel.IContainer container)
		{
			///
			/// Required for Windows.Forms Class Composition Designer support
			///
			container.Add(this);
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		public ShapeControl()
		{
			///
			/// Required for Windows.Forms Class Composition Designer support
			///
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}


		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			this.ForeColor = Color.BlueViolet;
		}
		#endregion


		protected override void OnRenderScene(Cerebrum.Direct3D.Forms.RenderEventArgs e)
		{
			base.OnRenderScene (e);

			Cerebrum.Direct3D.Drawing.Graphics _Graphics = Cerebrum.Direct3D.Drawing.Graphics.FromDevice(e.Device);
			_Graphics.DrawRectangle(this.SurfaceRectangle, this.m_Z, this.m_ForeColor, false);
/*

			VertexBuffer VertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColored), 4, device, Usage.WriteOnly, CustomVertex.TransformedColored.Format, Pool.SystemMemory);

			CustomVertex.TransformedColored[] verts = (CustomVertex.TransformedColored[])VertexBuffer.Lock(0,0); // Lock the buffer (which will return our structs)
			
			int clr = .ToArgb();

			float z = m_Z;

			RectangleF _rect = ;

			verts[0].SetPosition(new Vector4(_rect.Left, _rect.Top, z, 1.0f));
			verts[0].Color = clr;

			verts[1].SetPosition(new Vector4(_rect.Right - 1.5f, _rect.Top, z, 1.0f));
			verts[1].Color = clr;

			verts[2].SetPosition(new Vector4(_rect.Left, _rect.Bottom - 1.5f, z, 1.0f));
			verts[2].Color = clr;

			verts[3].SetPosition(new Vector4(_rect.Right - 1.5f, _rect.Bottom - 1.5f, z, 1.0f));
			verts[3].Color = clr;

			VertexBuffer.Unlock();

			device.VertexFormat = CustomVertex.TransformedColored.Format;

			// set the vertexbuffer stream source
			device.SetStreamSource(0, VertexBuffer, 0, VertexInformation.GetFormatSize(CustomVertex.TransformedColored.Format));
			// set fill mode
			device.RenderState.FillMode = FillMode.Solid;

			// set the indices			
			device.Indices = GetIndexBuffer(device);
			
			//use the indices buffer
			device.DrawIndexedPrimitives(PrimitiveType.LineStrip, 0, 0, 4, 0, 4);

			VertexBuffer.Dispose();*/
		}
	}
}
